package com.xixiu.theprojectthree.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xixiu.theprojectthree.common.entity.Book;
import com.xixiu.theprojectthree.dao.BookDao;
import com.xixiu.theprojectthree.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author XiXiu
 */
@Service
public class BookServiceImpl implements BookService {
    @Autowired
    private BookDao bookDao;

    @Override
    public Book queryById(Integer id) {
        return bookDao.queryById(id);
    }

    @Override
    public PageInfo<Book> queryAll(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Book> books = bookDao.queryAll();
        return new PageInfo<>(books);
    }

    @Override
    public int insert(Book book) {
        return bookDao.insert(book);
    }

    @Override
    public int update(Book book) {
        return bookDao.update(book);
    }

    @Override
    public int deleteById(Integer id) {
        return bookDao.deleteById(id);
    }
}
